package org.alex.nettychat.netty.custom.console;

import io.netty.channel.Channel;
import org.alex.nettychat.netty.custom.protocol.JoinGroupRequestPacket;
import org.alex.nettychat.netty.custom.protocol.SendToGroupRequestPacket;

import java.util.Scanner;

/**
 * @author : alex
 */
public class SendToGroup implements ConsoleCommand{
    @Override
    public void exec(Scanner scanner, Channel channel) {
        System.out.println("请输入群聊Id:");
        int groupId = Integer.valueOf(scanner.nextLine());
        System.out.println("请输入内容:");
        String msg = scanner.nextLine();
        SendToGroupRequestPacket sendToGroupRequestPacket = new SendToGroupRequestPacket();
        sendToGroupRequestPacket.setGroupId(groupId);
        sendToGroupRequestPacket.setMsg(msg);
        channel.writeAndFlush(sendToGroupRequestPacket);
    }
}
